package com.yuchen.core;

import java.io.Serializable;
import java.util.List;

/**
 *  @author Jack Q
 *  分页bean
 */
public class MyPager implements Serializable {

    private int pageSize = 20; //每页显示条数初始化，修改显示条数
    private int pageNo = 1; //当前第几页
    private long totalRecord;//总共多少条数据
    private int pageCount=-1; //总页数
    private List records;  // 分页数据

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public long getTotalRecord() {
        return totalRecord;
    }

    public void setTotalRecord(long totalRecord) {
        this.totalRecord = totalRecord;
        if (this.pageCount < 0)
            this.pageCount = (int) Math.ceil((double) totalRecord / pageSize);
    }

    public List getRecords() {
        return records;
    }

    public void setRecords(List records) {
        this.records = records;
    }

    public int getPageCount() {
        if (pageCount < 0)
            pageCount = (int) Math.ceil((double) totalRecord / pageSize);
        return pageCount;
    }

    //开始位置
    public int pageStart() {
        return pageSize * (pageNo-1);
    }
}
